package _06_动态规划;

public class _1567_乘积为正数的最长子数组长度 {

    public static void main(String[] args) {

        _1567_乘积为正数的最长子数组长度 v = new _1567_乘积为正数的最长子数组长度();

        int[] ins = {1000000000,1000000000};
        System.out.println(v.getMaxLen(ins));

    }

    public int getMaxLen(int[] nums) {
        int[] positive = new int[nums.length + 1];
        int[] negative = new int[nums.length + 1];
        int max = 0;
        for (int i = 1; i <= nums.length; i++) {
            if (nums[i - 1] > 0) {
                positive[i] = positive[i - 1] + 1;
                negative[i] = negative[i - 1] == 0? 0: negative[i - 1] + 1;
            } else if (nums[i - 1] < 0) {
                positive[i] = negative[i - 1] == 0? 0: negative[i - 1] + 1;
                negative[i] = positive[i - 1] + 1;
            } else {
                positive[i] = 0;
                negative[i] = 0;
            }
            max = Math.max(max, positive[i]);
        }
        return max;
    }

}
